//
//  PickerView.m
//  3级联动
//
//  Created by 陈亚勃 on 16/2/26.
//  Copyright © 2016年 cyb. All rights reserved.
//

#import "PickerView.h"
#import <FMDB.h>

#define BUTTON_WIDTH 100
#define BUTTON_HEIGHT 30

@interface PickerViewButton : UIButton

@end

@implementation PickerViewButton

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title{
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        self.backgroundColor = [UIColor yellowColor];
        [self setTitle:title forState:UIControlStateNormal];
        [self setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    }
    return self;
}



@end

@implementation PickerView 

- (instancetype)init{
    if (self = [super init]) {
        
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        [self setSubviewsWithFrame:frame];
    }
    return self;
}

- (void)setSubviewsWithFrame:(CGRect)frame{
    PickerViewButton *surebtn = [[PickerViewButton alloc] initWithFrame:CGRectMake(10, 10, BUTTON_WIDTH, BUTTON_HEIGHT) title:@"关闭"];
    [self addSubview:surebtn];
    
    PickerViewButton *cancelbtn = [[PickerViewButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - BUTTON_WIDTH - 10, 10, BUTTON_WIDTH, BUTTON_HEIGHT) title:@"保存"];
    [self addSubview:cancelbtn];
    
    UIPickerView *picker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(surebtn.frame)+20, SCREEN_WIDTH, CGRectGetMaxY(frame)-CGRectGetMaxY(surebtn.frame)-20)];
    picker.delegate = self;
    [self addSubview:picker];
    
    [self getData];
}

- (void)getData{
    
}

#pragma mark --- UIPickerViewDelegate,UIPickerViewDataSource
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 3;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    return 10;
}

@end
